package main

import (
	"gorm.io/driver/mysql"
	"log"

	//"github.com/gin-gonic/gin"
	//"log"
	//"net/http"
	"gorm.io/gorm"
)

func sql() *gorm.DB {
	dsn := "root:qyft664500@tcp(127.0.0.1:3306)/bookmaster?charset=utf8mb4&parseTime=True&loc=Local"
	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		log.Println("数据库连接错误", err)
	}
	db.AutoMigrate(&Book{})
	return db
}
